package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.FdsBusinessClosingRulesetService;
import com.yunhai.model.entity.fds.FdsBusinessClosingRulesetEntity;
import com.yunhai.model.vo.fds.FdsBusinessClosingRulesetQuery;
import com.yunhai.model.vo.fds.FdsBusinessClosingRulesetVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/fdsBusinessClosingRuleset")
public class FdsBusinessClosingRulesetController {

	@Resource
	private FdsBusinessClosingRulesetService fdsBusinessClosingRulesetService;


	/**
	 * 获取 FdsBusinessClosingRuleset 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getFdsBusinessClosingRulesetPagination(PaginationVo paginationVo, FdsBusinessClosingRulesetQuery fdsBusinessClosingRulesetQuery ) throws Exception {
		IPage page = fdsBusinessClosingRulesetService.getFdsBusinessClosingRulesetPagination(paginationVo, fdsBusinessClosingRulesetQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 FdsBusinessClosingRuleset 所有数据
	 */
	@GetMapping("/allList")
	public Ret getFdsBusinessClosingRulesetAllList( FdsBusinessClosingRulesetQuery fdsBusinessClosingRulesetQuery ) throws Exception {
		List<FdsBusinessClosingRulesetEntity> list = fdsBusinessClosingRulesetService.getFdsBusinessClosingRulesetAllList( fdsBusinessClosingRulesetQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 FdsBusinessClosingRuleset 详情
	 */
	@GetMapping("/{id}")
	public Ret getFdsBusinessClosingRulesetDetailById(@PathVariable Long id) throws Exception {

	    FdsBusinessClosingRulesetEntity fdsBusinessClosingRulesetEntity = fdsBusinessClosingRulesetService.getFdsBusinessClosingRulesetDetail(id);
		return Ret.ok(fdsBusinessClosingRulesetEntity);
	}


	/**
	 * 新增 FdsBusinessClosingRuleset
	 * */
	@PostMapping("")
	public Ret addFdsBusinessClosingRuleset(@RequestBody FdsBusinessClosingRulesetVo fdsBusinessClosingRulesetVo) throws Exception {

		fdsBusinessClosingRulesetService.addFdsBusinessClosingRuleset(fdsBusinessClosingRulesetVo);
		return Ret.ok();
	}


	/**
	 * 更新 FdsBusinessClosingRuleset
	 * */
	@PutMapping("")
	public Ret updateFdsBusinessClosingRuleset(@RequestBody FdsBusinessClosingRulesetVo fdsBusinessClosingRulesetVo) throws Exception {

		fdsBusinessClosingRulesetService.updateFdsBusinessClosingRuleset(fdsBusinessClosingRulesetVo);
		return Ret.ok();
	}


	/**
	 * 删除 FdsBusinessClosingRuleset
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveFdsBusinessClosingRuleset( @RequestBody List<Long> ids ) throws Exception {

	    fdsBusinessClosingRulesetService.batchRemoveFdsBusinessClosingRuleset(ids);
		return Ret.ok();
	}
}
